/**
 * $Id: Holder.java,v 1.5 2005/10/11 19:22:08 olu Exp $
 */
package tripleo.adt;

/**
 * Generally equivalent to Maybe a in Haskell
 */
public class Holder<Q> {
	/*final*/ private Q       held;
	final private boolean empty;

	public Holder(Q i) {
		held = i;
		empty = false;
	}

	public Holder() {
		held  = null;
		empty = true;
	}

	public boolean isEmpty() {
		return empty;
	}

	public Q get() {
		if (isEmpty()) throw new RuntimeException("attempt to `get()' on Empty Holder");
		return held;
	}

	public void set(Q i) {
		held=i;
		
	}
}
